Returns a formatted string using values from an array.
Syntax
Format("FormatString", ArrayOfValues)
Arguments
| Argument | Description |
|---|---|
| FormatString | String to format. |
| ArrayOfValues | Array name that holds the values to format. |
The following specifiers are supported for formatting common numeric values. Array indexes must be in curly braces ({}). Separate the index and specifier with a colon. Indexes are zero based.
| Specifier | Type | Format | Output (Passed Double 1.42) | Output (Passed Int -12400) |
|---|---|---|---|---|
| c | Currency | {0:c} | $1.42 | -$12,400 |
| d | Decimal (Whole number) | {0:d} | -12400 | |
| e | Scientific | {0:e} | 1.420000e+000 | -1.240000e+004 |
| f | Fixed point | {0:f} | 1.42 | -12400.00 |
| g | General | {0:g} | 1.42 | -12400 |
| n | Number with commas for thousands | {0:n} | 1.42 | -12,400 |
| r | Round trippable | {0:r} | 1.42 | |
| x | Hexadecimal | {0:x4} | cf90 |
Custom number formatting characters
The following specifiers are also supported for custom formatting of numeric values.
| Specifier | Type | Example | Output (Passed Double 1500.42) | Notes |
|---|---|---|---|---|
| 0 | Zero placeholder | {0:00.0000} | 1500.4200 | Pads with zeroes |
| # | Digit placeholder | {0:(#).##} | (1500).42 | |
| . | Decimal point | {0:0.0} | 1500.4 | |
| , | Thousand separator | {0:0,0} | 1,500 | Must be between two zeroes |
| % | Percent | {0:0%} | 150042% | Multiplies by 100, adds% sign |
| e | Exponent placeholder | {0:00e+0} | 15e+2 | Many exponent formats available |
Return value
| Value | Description |
|---|---|
| Value | Formatted string of values from the array. |
Example
Dim arrayValues(2)
arrayValues(1) = "WysiWrite"
arrayValues(2) = 24.99
var = Format("{0} subscription license: {1:c} per month", arrayValues)
PrintLn(var)